import java.util.concurrent.Callable;

class Person {
    static void sayCountry() {
        System.out.println("sayCountry is runing");
    }

    static int getSomeThing() {
        System.out.println("getSomeThing is runing");
        return 1;
    }
}

public class Test {
    public static void main(String[] args) {
        // Runnable 适合“** fire-and-forget **”的任务；
        // Callable 适合“** 执行后要拿结果（或抛异常）”的任务；
        // 两者都是函数式接口，都能用 Lambda / 方法引用，但有无返回值和能否抛受检异常**是核心区别。
        runnable_demo();
        callable_demo();
    }

    public static void runnable_demo() {
        // @FunctionalInterface
        // public interface Runnable {
        // void run();
        // }
        Runnable fn = Person::sayCountry;
        fn.run();
    }

    public static void callable_demo() {
        // @FunctionalInterface
        // public interface Callable<V> {
        // V call() throws Exception;
        // }
        Callable<Integer> c1 = Person::getSomeThing;
        try {
            c1.call();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}